home *** CD-ROM | disk | FTP | other *** search
/ This Disc Bytes! / Power Computing - The Disc 2 - This Disc Bytes.ISO / mac / CodeWarrior 7 Lite for 68K / MacOS Support / Headers / Universal Headers / Devices.h < prev    next >
Text File  |  1995-07-06  |  15KB  |  482 lines

  1. /*
  2.      File:        Devices.h
  3.  
  4.      Contains:    Device Manager Interfaces.
  5.  
  6.      Version:    Technology:    System 7.5
  7.                  Package:    Universal Interfaces 2.1 in “MPW Latest” on ETO #18
  8.  
  9.      Copyright:    © 1984-1995 by Apple Computer, Inc.
  10.                  All rights reserved.
  11.  
  12.      Bugs?:        If you find a problem with this file, use the Apple Bug Reporter
  13.                  stack.  Include the file and version information (from above)
  14.                  in the problem description and send to:
  15.                      Internet:    apple.bugs@applelink.apple.com
  16.                      AppleLink:    APPLE.BUGS
  17.  
  18. */
  19.  
  20. #ifndef __DEVICES__
  21. #define __DEVICES__
  22.  
  23.  
  24. #ifndef __OSUTILS__
  25. #include <OSUtils.h>
  26. #endif
  27. /*    #include <Types.h>                                            */
  28. /*        #include <ConditionalMacros.h>                            */
  29. /*    #include <MixedMode.h>                                        */
  30. /*    #include <Memory.h>                                            */
  31.  
  32. #ifndef __FILES__
  33. #include <Files.h>
  34. #endif
  35. /*    #include <Finder.h>                                            */
  36.  
  37. #ifndef __QUICKDRAW__
  38. #include <Quickdraw.h>
  39. #endif
  40. /*    #include <QuickdrawText.h>                                    */
  41.  
  42. #ifndef __EVENTS__
  43. #include <Events.h>
  44. #endif
  45.  
  46. #ifndef __DIALOGS__
  47. #include <Dialogs.h>
  48. #endif
  49. /*    #include <Errors.h>                                            */
  50. /*    #include <Menus.h>                                            */
  51. /*    #include <Controls.h>                                        */
  52. /*    #include <Windows.h>                                        */
  53. /*    #include <TextEdit.h>                                        */
  54.  
  55. #ifdef __cplusplus
  56. extern "C" {
  57. #endif
  58.  
  59. #if PRAGMA_ALIGN_SUPPORTED
  60. #pragma options align=mac68k
  61. #endif
  62.  
  63. #if PRAGMA_IMPORT_SUPPORTED
  64. #pragma import on
  65. #endif
  66.  
  67.  
  68. enum {
  69.     chooserInitMsg                = 11,                            /* the user selected this device package */
  70.     newSelMsg                    = 12,                            /* the user made new device selections */
  71.     fillListMsg                    = 13,                            /* fill the device list with choices */
  72.     getSelMsg                    = 14,                            /* mark one or more choices as selected */
  73.     selectMsg                    = 15,                            /* the user made a selection */
  74.     deselectMsg                    = 16,                            /* the user canceled a selection */
  75.     terminateMsg                = 17,                            /* allows device package to clean up */
  76.     buttonMsg                    = 19                            /* the user selected a button */
  77. };
  78.  
  79. /* Values of the 'caller' parameter to a Chooser device package */
  80. enum {
  81.     chooserID                    = 1
  82. };
  83.  
  84. /* Values of the 'message' parameter to a Control Panel 'cdev' */
  85. enum {
  86.     initDev                        = 0,                            /*Time for cdev to initialize itself*/
  87.     hitDev                        = 1,                            /*Hit on one of my items*/
  88.     closeDev                    = 2,                            /*Close yourself*/
  89.     nulDev                        = 3,                            /*Null event*/
  90.     updateDev                    = 4,                            /*Update event*/
  91.     activDev                    = 5,                            /*Activate event*/
  92.     deactivDev                    = 6,                            /*Deactivate event*/
  93.     keyEvtDev                    = 7,                            /*Key down/auto key*/
  94.     macDev                        = 8,                            /*Decide whether or not to show up*/
  95.     undoDev                        = 9,
  96.     cutDev                        = 10,
  97.     copyDev                        = 11,
  98.     pasteDev                    = 12,
  99.     clearDev                    = 13,
  100.     cursorDev                    = 14
  101. };
  102.  
  103. /* Special values a Control Panel 'cdev' can return */
  104. enum {
  105.     cdevGenErr                    = -1,                            /*General error; gray cdev w/o alert*/
  106.     cdevMemErr                    = 0,                            /*Memory shortfall; alert user please*/
  107.     cdevResErr                    = 1,                            /*Couldn't get a needed resource; alert*/
  108.     cdevUnset                    = 3                                /* cdevValue is initialized to this*/
  109. };
  110.  
  111. /* Values of the 'message' parameter to a Monitor 'mntr' */
  112. enum {
  113.     initMsg                        = 1,                            /*initialization*/
  114.     okMsg                        = 2,                            /*user clicked OK button*/
  115.     cancelMsg                    = 3,                            /*user clicked Cancel button*/
  116.     hitMsg                        = 4,                            /*user clicked control in Options dialog*/
  117.     nulMsg                        = 5,                            /*periodic event*/
  118.     updateMsg                    = 6,                            /*update event*/
  119.     activateMsg                    = 7,                            /*not used*/
  120.     deactivateMsg                = 8,                            /*not used*/
  121.     keyEvtMsg                    = 9,                            /*keyboard event*/
  122.     superMsg                    = 10,                            /*show superuser controls*/
  123.     normalMsg                    = 11,                            /*show only normal controls*/
  124.     startupMsg                    = 12                            /*code has been loaded*/
  125. };
  126.  
  127. /* control codes for DeskAccessories */
  128. enum {
  129.     goodbye                        = -1,                            /* heap being reinitialized */
  130.     killCode                    = 1,                            /* KillIO requested */
  131.     accEvent                    = 64,                            /* handle an event */
  132.     accRun                        = 65,                            /* time for periodic action */
  133.     accCursor                    = 66,                            /* change cursor shape */
  134.     accMenu                        = 67,                            /* handle menu item */
  135.     accUndo                        = 68,                            /* handle undo command */
  136.     accCut                        = 70,                            /* handle cut command */
  137.     accCopy                        = 71,                            /* handle copy command */
  138.     accPaste                    = 72,                            /* handle paste command */
  139.     accClear                    = 73                            /* handle clear command */
  140. };
  141.  
  142. /* Control/Status Call Codes */
  143. enum {
  144.     drvStsCode                    = 8,                            /* status call code for drive status */
  145.     ejectCode                    = 7,                            /* control call eject code */
  146.     tgBuffCode                    = 8                                /* set tag buffer code */
  147. };
  148.  
  149. /* miscellaneous Device Manager constants */
  150. enum {
  151.     ioInProgress                = 1,                            /* predefined value of ioResult while I/O is pending */
  152.     aRdCmd                        = 2,                            /* low byte of ioTrap for Read calls */
  153.     aWrCmd                        = 3,                            /* low byte of ioTrap for Write calls */
  154.     asyncTrpBit                    = 10,                            /* trap word modifier */
  155.     noQueueBit                    = 9                                /* trap word modifier */
  156. };
  157.  
  158. /* flags used in the driver header and device control entry */
  159. enum {
  160.     dReadEnable                    = 0,                            /* set if driver responds to read requests */
  161.     dWritEnable                    = 1,                            /* set if driver responds to write requests */
  162.     dCtlEnable                    = 2,                            /* set if driver responds to control requests */
  163.     dStatEnable                    = 3,                            /* set if driver responds to status requests */
  164.     dNeedGoodBye                = 4,                            /* set if driver needs time for performing periodic tasks */
  165.     dNeedTime                    = 5,                            /* set if driver needs time for performing periodic tasks */
  166.     dNeedLock                    = 6,                            /* set if driver must be locked in memory as soon as it is opened */
  167.     dNeedLockMask                = 0x4000,                        /* set if driver must be locked in memory as soon as it is opened */
  168.     dNeedTimeMask                = 0x2000,                        /* set if driver needs time for performing periodic tasks */
  169.     dNeedGoodByeMask            = 0x1000,                        /* set if driver needs to be called before the application heap is initialized */
  170.     dStatEnableMask                = 0x0800,                        /* set if driver responds to status requests */
  171.     dCtlEnableMask                = 0x0400,                        /* set if driver responds to control requests */
  172.     dWritEnableMask                = 0x0200,                        /* set if driver responds to write requests */
  173.     dReadEnableMask                = 0x0100                        /* set if driver responds to read requests */
  174. };
  175.  
  176. /* run-time flags used in the device control entry */
  177. enum {
  178.     dOpened                        = 5,                            /* driver is open */
  179.     dRAMBased                    = 6,                            /* dCtlDriver is a handle (1) or pointer (0) */
  180.     drvrActive                    = 7,                            /* driver is currently processing a request */
  181.     drvrActiveMask                = 0x0080,                        /* driver is currently processing a request */
  182.     dRAMBasedMask                = 0x0040,                        /* dCtlDriver is a handle (1) or pointer (0) */
  183.     dOpenedMask                    = 0x0020                        /* driver is open */
  184. };
  185.  
  186. struct DRVRHeader {
  187.     short                            drvrFlags;
  188.     short                            drvrDelay;
  189.     short                            drvrEMask;
  190.     short                            drvrMenu;
  191.     short                            drvrOpen;
  192.     short                            drvrPrime;
  193.     short                            drvrCtl;
  194.     short                            drvrStatus;
  195.     short                            drvrClose;
  196.     unsigned char                    drvrName[1];
  197. };
  198. typedef struct DRVRHeader DRVRHeader;
  199.  
  200. typedef DRVRHeader *DRVRHeaderPtr, **DRVRHeaderHandle;
  201.  
  202. struct DCtlEntry {
  203.     Ptr                                dCtlDriver;
  204.     short                            dCtlFlags;
  205.     QHdr                            dCtlQHdr;
  206.     long                            dCtlPosition;
  207.     Handle                            dCtlStorage;
  208.     short                            dCtlRefNum;
  209.     long                            dCtlCurTicks;
  210.     WindowPtr                        dCtlWindow;
  211.     short                            dCtlDelay;
  212.     short                            dCtlEMask;
  213.     short                            dCtlMenu;
  214. };
  215. typedef struct DCtlEntry DCtlEntry;
  216.  
  217. typedef DCtlEntry *DCtlPtr, **DCtlHandle;
  218.  
  219. struct AuxDCE {
  220.     Ptr                                dCtlDriver;
  221.     short                            dCtlFlags;
  222.     QHdr                            dCtlQHdr;
  223.     long                            dCtlPosition;
  224.     Handle                            dCtlStorage;
  225.     short                            dCtlRefNum;
  226.     long                            dCtlCurTicks;
  227.     GrafPtr                            dCtlWindow;
  228.     short                            dCtlDelay;
  229.     short                            dCtlEMask;
  230.     short                            dCtlMenu;
  231.     SInt8                            dCtlSlot;
  232.     SInt8                            dCtlSlotId;
  233.     long                            dCtlDevBase;
  234.     Ptr                                dCtlOwner;
  235.     SInt8                            dCtlExtDev;
  236.     SInt8                            fillByte;
  237.     UInt32                            dCtlNodeID;
  238. };
  239. typedef struct AuxDCE AuxDCE;
  240.  
  241. typedef AuxDCE *AuxDCEPtr, **AuxDCEHandle;
  242.  
  243. #if !OLDROUTINELOCATIONS
  244.  
  245. #if !GENERATINGCFM
  246. #pragma parameter __D0 PBOpenSync(__A0)
  247. #endif
  248. extern pascal OSErr PBOpenSync(ParmBlkPtr paramBlock)
  249.  ONEWORDINLINE(0xA000);
  250.  
  251. #if !GENERATINGCFM
  252. #pragma parameter __D0 PBOpenAsync(__A0)
  253. #endif
  254. extern pascal OSErr PBOpenAsync(ParmBlkPtr paramBlock)
  255.  ONEWORDINLINE(0xA400);
  256.  
  257. #if !GENERATINGCFM
  258. #pragma parameter __D0 PBOpenImmed(__A0)
  259. #endif
  260. extern pascal OSErr PBOpenImmed(ParmBlkPtr paramBlock)
  261.  ONEWORDINLINE(0xA200);
  262.  
  263. #if !GENERATINGCFM
  264. #pragma parameter __D0 PBCloseSync(__A0)
  265. #endif
  266. extern pascal OSErr PBCloseSync(ParmBlkPtr paramBlock)
  267.  ONEWORDINLINE(0xA001);
  268.  
  269. #if !GENERATINGCFM
  270. #pragma parameter __D0 PBCloseAsync(__A0)
  271. #endif
  272. extern pascal OSErr PBCloseAsync(ParmBlkPtr paramBlock)
  273.  ONEWORDINLINE(0xA401);
  274.  
  275. #if !GENERATINGCFM
  276. #pragma parameter __D0 PBCloseImmed(__A0)
  277. #endif
  278. extern pascal OSErr PBCloseImmed(ParmBlkPtr paramBlock)
  279.  ONEWORDINLINE(0xA201);
  280.  
  281. #if !GENERATINGCFM
  282. #pragma parameter __D0 PBReadSync(__A0)
  283. #endif
  284. extern pascal OSErr PBReadSync(ParmBlkPtr paramBlock)
  285.  ONEWORDINLINE(0xA002);
  286.  
  287. #if !GENERATINGCFM
  288. #pragma parameter __D0 PBReadAsync(__A0)
  289. #endif
  290. extern pascal OSErr PBReadAsync(ParmBlkPtr paramBlock)
  291.  ONEWORDINLINE(0xA402);
  292.  
  293. #if !GENERATINGCFM
  294. #pragma parameter __D0 PBReadImmed(__A0)
  295. #endif
  296. extern pascal OSErr PBReadImmed(ParmBlkPtr paramBlock)
  297.  ONEWORDINLINE(0xA202);
  298.  
  299. #if !GENERATINGCFM
  300. #pragma parameter __D0 PBWriteSync(__A0)
  301. #endif
  302. extern pascal OSErr PBWriteSync(ParmBlkPtr paramBlock)
  303.  ONEWORDINLINE(0xA003);
  304.  
  305. #if !GENERATINGCFM
  306. #pragma parameter __D0 PBWriteAsync(__A0)
  307. #endif
  308. extern pascal OSErr PBWriteAsync(ParmBlkPtr paramBlock)
  309.  ONEWORDINLINE(0xA403);
  310.  
  311. #if !GENERATINGCFM
  312. #pragma parameter __D0 PBWriteImmed(__A0)
  313. #endif
  314. extern pascal OSErr PBWriteImmed(ParmBlkPtr paramBlock)
  315.  ONEWORDINLINE(0xA203);
  316. extern pascal void AddDrive(short drvrRefNum, short drvNum, DrvQElPtr qEl);
  317. extern pascal QHdrPtr GetDrvQHdr(void)
  318.  THREEWORDINLINE(0x2EBC, 0x0000, 0x0308);
  319. #endif
  320. /* Control Panel Default Proc */
  321. typedef pascal long (*ControlPanelDefProcPtr)(short message, short item, short numItems, short cPanelID, EventRecord *theEvent, long cdevValue, DialogPtr cpDialog);
  322.  
  323. #if GENERATINGCFM
  324. typedef UniversalProcPtr ControlPanelDefUPP;
  325. #else
  326. typedef ControlPanelDefProcPtr ControlPanelDefUPP;
  327. #endif
  328.  
  329. enum {
  330.     uppControlPanelDefProcInfo = kPascalStackBased
  331.          | RESULT_SIZE(SIZE_CODE(sizeof(long)))
  332.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(short)))
  333.          | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(short)))
  334.          | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(short)))
  335.          | STACK_ROUTINE_PARAMETER(4, SIZE_CODE(sizeof(short)))
  336.          | STACK_ROUTINE_PARAMETER(5, SIZE_CODE(sizeof(EventRecord*)))
  337.          | STACK_ROUTINE_PARAMETER(6, SIZE_CODE(sizeof(long)))
  338.          | STACK_ROUTINE_PARAMETER(7, SIZE_CODE(sizeof(DialogPtr)))
  339. };
  340.  
  341. #if GENERATINGCFM
  342. #define NewControlPanelDefProc(userRoutine)        \
  343.         (ControlPanelDefUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppControlPanelDefProcInfo, GetCurrentArchitecture())
  344. #else
  345. #define NewControlPanelDefProc(userRoutine)        \
  346.         ((ControlPanelDefUPP) (userRoutine))
  347. #endif
  348.  
  349. #if GENERATINGCFM
  350. #define CallControlPanelDefProc(userRoutine, message, item, numItems, cPanelID, theEvent, cdevValue, cpDialog)        \
  351.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppControlPanelDefProcInfo, (message), (item), (numItems), (cPanelID), (theEvent), (cdevValue), (cpDialog))
  352. #else
  353. #define CallControlPanelDefProc(userRoutine, message, item, numItems, cPanelID, theEvent, cdevValue, cpDialog)        \
  354.         (*(userRoutine))((message), (item), (numItems), (cPanelID), (theEvent), (cdevValue), (cpDialog))
  355. #endif
  356.  
  357. extern pascal DCtlHandle GetDCtlEntry(short refNum);
  358. /*
  359.     SetChooserAlert used to simply set a bit in a low-mem global
  360.     to tell the Chooser not to display its warning message when
  361.     the printer is changed. However, under MultiFinder and System 7,
  362.     this low-mem is swapped out when a layer change occurs, and the
  363.     Chooser never sees the change. It is obsolete, and completely
  364.     unsupported on the PowerPC. 68K apps can still call it if they
  365.     wish.
  366. */
  367. #if OLDROUTINENAMES && !GENERATINGCFM
  368. extern pascal Boolean SetChooserAlert(Boolean f);
  369. #endif
  370. /*
  371.   Note: DrvrInstall() is no longer supported, becuase it never really worked anyways.
  372.           There will soon be a DriverInstall() which does the right thing.
  373.  
  374.         DrvrRemove has been renamed to DriverRemove.  But, InterfaceLib for PowerPC
  375.         still exports DrvrRemove, so a macro is used to map the new name to old.
  376.  
  377. */
  378.  
  379. #if !GENERATINGCFM
  380. #pragma parameter __D0 DrvrRemove(__D0)
  381. #endif
  382. extern pascal OSErr DrvrRemove(short refNum)
  383.  ONEWORDINLINE(0xA03E);
  384. #define DriverRemove(refNum) DrvrRemove(refNum)
  385. extern pascal OSErr OpenDriver(ConstStr255Param name, short *drvrRefNum);
  386. extern pascal OSErr CloseDriver(short refNum);
  387. extern pascal OSErr Control(short refNum, short csCode, const void *csParamPtr);
  388. extern pascal OSErr Status(short refNum, short csCode, void *csParamPtr);
  389. extern pascal OSErr KillIO(short refNum);
  390.  
  391. #if !GENERATINGCFM
  392. #pragma parameter __D0 PBControlSync(__A0)
  393. #endif
  394. extern pascal OSErr PBControlSync(ParmBlkPtr paramBlock)
  395.  ONEWORDINLINE(0xA004);
  396.  
  397. #if !GENERATINGCFM
  398. #pragma parameter __D0 PBControlAsync(__A0)
  399. #endif
  400. extern pascal OSErr PBControlAsync(ParmBlkPtr paramBlock)
  401.  ONEWORDINLINE(0xA404);
  402.  
  403. #if !GENERATINGCFM
  404. #pragma parameter __D0 PBControlImmed(__A0)
  405. #endif
  406. extern pascal OSErr PBControlImmed(ParmBlkPtr paramBlock)
  407.  ONEWORDINLINE(0xA204);
  408.  
  409. #if !GENERATINGCFM
  410. #pragma parameter __D0 PBStatusSync(__A0)
  411. #endif
  412. extern pascal OSErr PBStatusSync(ParmBlkPtr paramBlock)
  413.  ONEWORDINLINE(0xA005);
  414.  
  415. #if !GENERATINGCFM
  416. #pragma parameter __D0 PBStatusAsync(__A0)
  417. #endif
  418. extern pascal OSErr PBStatusAsync(ParmBlkPtr paramBlock)
  419.  ONEWORDINLINE(0xA405);
  420.  
  421. #if !GENERATINGCFM
  422. #pragma parameter __D0 PBStatusImmed(__A0)
  423. #endif
  424. extern pascal OSErr PBStatusImmed(ParmBlkPtr paramBlock)
  425.  ONEWORDINLINE(0xA205);
  426.  
  427. #if !GENERATINGCFM
  428. #pragma parameter __D0 PBKillIOSync(__A0)
  429. #endif
  430. extern pascal OSErr PBKillIOSync(ParmBlkPtr paramBlock)
  431.  ONEWORDINLINE(0xA006);
  432.  
  433. #if !GENERATINGCFM
  434. #pragma parameter __D0 PBKillIOAsync(__A0)
  435. #endif
  436. extern pascal OSErr PBKillIOAsync(ParmBlkPtr paramBlock)
  437.  ONEWORDINLINE(0xA406);
  438.  
  439. #if !GENERATINGCFM
  440. #pragma parameter __D0 PBKillIOImmed(__A0)
  441. #endif
  442. extern pascal OSErr PBKillIOImmed(ParmBlkPtr paramBlock)
  443.  ONEWORDINLINE(0xA206);
  444. extern pascal short OpenDeskAcc(ConstStr255Param deskAccName)
  445.  ONEWORDINLINE(0xA9B6);
  446. extern pascal void CloseDeskAcc(short refNum)
  447.  ONEWORDINLINE(0xA9B7);
  448. #if CGLUESUPPORTED
  449. extern short opendeskacc(const char *deskAccName);
  450. extern OSErr opendriver(const char *driverName, short *refNum);
  451. #endif
  452. #if OLDROUTINENAMES
  453. /*
  454.     The PBxxx() routines are obsolete.  
  455.     
  456.     Use the PBxxxSync(), PBxxxAsync(), or PBxxxImmed version instead.
  457. */
  458. #define PBControl(pb, async) ((async) ? PBControlAsync(pb) : PBControlSync(pb))
  459. #define PBStatus(pb, async) ((async) ? PBStatusAsync(pb) : PBStatusSync(pb))
  460. #define PBKillIO(pb, async) ((async) ? PBKillIOAsync(pb) : PBKillIOSync(pb))
  461. #if !OLDROUTINELOCATIONS
  462. #define PBOpen(pb, async) ((async) ? PBOpenAsync(pb) : PBOpenSync(pb))
  463. #define PBClose(pb, async) ((async) ? PBCloseAsync(pb) : PBCloseSync(pb))
  464. #define PBRead(pb, async) ((async) ? PBReadAsync(pb) : PBReadSync(pb))
  465. #define PBWrite(pb, async) ((async) ? PBWriteAsync(pb) : PBWriteSync(pb))
  466. #endif
  467. #endif
  468.  
  469. #if PRAGMA_IMPORT_SUPPORTED
  470. #pragma import off
  471. #endif
  472.  
  473. #if PRAGMA_ALIGN_SUPPORTED
  474. #pragma options align=reset
  475. #endif
  476.  
  477. #ifdef __cplusplus
  478. }
  479. #endif
  480.  
  481. #endif /* __DEVICES__ */
  482.